package com.woniuxy.service.impl;

import com.woniuxy.dao.StopCarMapper;
import com.woniuxy.pojo.StopCar;
import com.woniuxy.service.StopCarService;
import javafx.scene.paint.Stop;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Service
public class StopCarServiceImpl implements StopCarService {


    @Autowired
    private StopCarMapper stopCarMapper;

    //查看正停放在小区的车辆
    @Override
    public List<StopCar> findAllCar() {
        return stopCarMapper.findAllCar();
    }

    //查询所有的历史记录
    @Override
    public List<StopCar> findEzstopCar() {
        return stopCarMapper.findEzstopCar();
    }

    //根据车牌号查询该车辆是否在小区
    @Override
    public StopCar findCarByCarnumber(String carnumber) {
        return stopCarMapper.findCarByCarnumber(carnumber);
    }

    //停车，存入数据库
    @Override
    public void stopcar(String carnumber) {
        StopCar sc = new StopCar();
        sc.setCarnumber(carnumber);
        sc.setCreatetime(new Date());
        sc.setStatus(1);
        stopCarMapper.insertSelective(sc);
    }

    //查询该车辆是否在小区内
    @Override
    public StopCar findCarById(Long id) {
        return stopCarMapper.findCarById(id);
    }

    //车辆离开小区，更改状态码
    @Override
    public void updateStatusById(Long id) {
        //添加离开时间，修改状态码
        stopCarMapper.updateStatusById(id,new Date());
    }


}
